//
//  PicViewController.m
//  TrueLove
//
//  Created by dlios on 15-1-29.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "PicViewController.h"
#import "AFHTTPRequestOperationManager.h"
#import "UIImageView+WebCache.h"
@interface PicViewController ()

@property (nonatomic, retain)NSMutableDictionary *dicPic;

@end


@implementation PicViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"主题详情";
    [self getUrl];
    
    
}

- (void)getUrl
{
    NSString *str1 = @"http://www.hunliji.com/subjects/";
    NSString *str2 = self.myID;
    NSString *str3 = @".json";
    NSString *str = [NSString stringWithFormat:@"%@%@%@",str1,str2,str3];
    NSLog(@"%@",str);
    
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    [manger GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        //NSLog(@"========%@",responseObject);
        self.dicPic = responseObject;
        NSLog(@"======%@",self.dicPic);
        
        [self createUIView];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error);
    }];
    
    
    
}

- (void)createUIView
{
    
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    //view.backgroundColor = [UIColor grayColor];
    [self.view addSubview:view];
    [view release];
    NSString *allPic = [[self.dicPic objectForKey:@"subject"] objectForKey:@"bkg_path"];
    NSLog(@"========%@",allPic);
    NSURL *url = [NSURL URLWithString:allPic];
    UIImageView *iamgeView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    iamgeView.backgroundColor = [UIColor cyanColor];
    [iamgeView setImageWithURL:url];
    [view addSubview:iamgeView];
    [iamgeView release];
    
    
    
    
    
    
    
}










- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
